<?php
	define(IMPORT,'../class.mamatblog/',true);
	require_once(IMPORT.'mysql.php');
	require_once(IMPORT.'comment.php');
	require_once(IMPORT.'page.php');	

	//comment
	$comm = new Comment();
	
	//page
	$pageDetailId = addslashes($_REQUEST['p']);
	$pageMain = new Page();
	$pageDetail = $pageMain->getPage($pageDetailId);
	for($i = 0; $i < count($pageDetail); $i++) {
?>

<h2 class="first" style=""><a href="#" id="author" onclick="makeRequest('mainpagedetail.php?p=<?php echo $pageDetail[$i][0];?>','main','Tunggu yak lagi Loading main page..!')"><?php echo $pageDetail[$i][2];?></a></h2>
			
<p class="postdata">
	Posted on <?php echo $pageDetail[$i][1];?> by <a href="#"><?php echo $pageMain->getPageAuthor($pageDetail[$i][5]);?></a> || <a href="#" onclick="makeRequest('maincomment.php?page=<?php echo $pageDetail[$i][0];?>','comment','loading page...');"><?php echo $comm->getCommentRows($pageDetail[$i][0]);?> Comments</a>

</p>

<div id = "comment" style="color:#C0C0C0"></div>

<p>
<?php
$myPage = $pageDetail[$i][3];
$myPage1 = explode("code]",$myPage);
$myPage = "";
for($i=0;$i<count($myPage1);$i++){
	if($i%2==0){
		$myPage.="
		".nl2br(substr($myPage1[$i],0,-1))."		
		";
	} else {
		$myPage.="
		<div style=\"background-color:#000000;\">
			<pre>
				".htmlentities(substr($myPage1[$i],0,-2))."
			</pre>
		</div>
		";
	}
}
$cont = $myPage;
echo $cont;
?>
	<?php //echo nl2br(str_replace('[/code]','</pre></div>',(str_replace('[code]','<div style="background-color:#000000;"><pre>',$pageDetail[$i][3])))) ;?>
</p>

<p>
	<h3><a href="#" onclick="makeRequest('maincomment.php?page=<?php echo $pageDetail[$i][0];?>','comment','loading page...');">Comment...</a></h3>
</p>


<?php
	}
	$subTitle = $pageMain->getPageTitle($pageDetail[0][4]);
?>
<h3>Other Articles</h3>
<ul>
<?php
	for($i = 0; $i < count($subTitle); $i++){
?>

<li><a href="#" onclick="makeRequest('mainpagedetail.php?p=<?php echo $subTitle[$i][0];?>','main','Tunggu yak lagi Loading detail page..!')"><?php echo $subTitle[$i][2]?></a>|<?php echo $pageMain->getPageAuthor($subTitle[$i][4]);?>, <?php echo $subTitle[$i][1];?></li>

<?php 
	}
?>
</ol>
